package name.marz.to.go.ahg.saison.executer;

import name.marz.to.go.ahg.core.checker.DocumentChecker;
import name.marz.to.go.ahg.core.exception.CannotLoginException;
import name.marz.to.go.ahg.core.exception.UserProcessException;

import org.jsoup.nodes.Document;

public class SaisonLoginChecker implements DocumentChecker {
	private static final String ERR_UNCORRECT_PASSWD1 = "IDもしくはパスワードの入力値に誤りがあります。";
	
	@Override
	public void check(Document doc) throws UserProcessException {
		// ログインエラーチェック
		if ( doc.body().html().contains(ERR_UNCORRECT_PASSWD1)) {
			CannotLoginException cle = new CannotLoginException(
					doc.body().getElementsContainingOwnText(ERR_UNCORRECT_PASSWD1).first().text()
					);
			cle.setDocument(doc);
			throw cle;
		}
	}
}